package com.prestamomo.vil.ppa.pmvilpage;

import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.prestamomo.vil.ppa.R;
import com.prestamomo.vil.ppa.pmvilpage.pmrot.PmvilAtyRoot;

public class PmvilWebAtVy extends PmvilAtyRoot {

    private String pmvilTitle;
    private String pmvilUrl;
    private ImageView webatPmvilBack;
    private TextView webatPmvilTitle;
    private WebView webatPmvilWebs;

    @Override
    protected int getPmvilLayoutId() {
        return R.layout.webat_pmvil_ly;
    }

    @Override
    protected void showPmvilUi() {

        pmvilTitle = getIntent().getStringExtra("pmvil_title");
        pmvilUrl = getIntent().getStringExtra("pmvil_url");
        webatPmvilBack = findViewById(R.id.webat_pmvil_iv_back);
        webatPmvilTitle = findViewById(R.id.webat_pmvil_tv_title);
        webatPmvilWebs = findViewById(R.id.webat_pmvil_webs);
        webatPmvilTitle.setText(pmvilTitle);

        WebSettings pmvilWebSettings = webatPmvilWebs.getSettings();
        pmvilWebSettings.setJavaScriptEnabled(true);
        pmvilWebSettings.setUseWideViewPort(true);
        pmvilWebSettings.setLoadWithOverviewMode(true);
        pmvilWebSettings.setSupportZoom(true);
        pmvilWebSettings.setBuiltInZoomControls(true);
        pmvilWebSettings.setDisplayZoomControls(false);
        pmvilWebSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        pmvilWebSettings.setAllowFileAccess(true);
        pmvilWebSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        pmvilWebSettings.setLoadsImagesAutomatically(true);
        webatPmvilWebs.loadUrl(pmvilUrl);

    }

    @Override
    protected void clickePmvil() {
        webatPmvilBack.setOnClickListener(v -> finish());
    }

    @Override
    protected void loadPmvilData() {

    }
}
